import request from '@/utils/request'
import {download} from '@/utils/request'
import {getNowDate} from '@/utils/tools.js'


// 分页获取活动列表
export function getActivityList(params) {
  return request({
    url: '/system/acddActivity/list',
    method: 'get',
    params
  })
}


// 新建活动
export function addActivity(data) {
  return request({
    url: '/system/acddActivity/add',
    method: 'POST',
    data
  })
}

// 修改活动
export function editActivity(data) {
  return request({
    url: '/system/acddActivity/edit',
    method: 'post',
    data
  })
}

// 删除活动
export function delActivity(ids) {
  return request({
    url: `/system/acddActivity/remove/${ids}`,
    method: 'post'
  })
}

// 终止活动
export function stopActivity(ids) {
  return request({
    url: `/system/acddActivity/activityCease/${ids}`,
    method: 'post'
  })
}

// 活动查询(查看)
export function getActivityDetail(id) {
  return request({
    url: `/system/acddActivity/getInfo/${id}`,
    method: 'GET'
  })
}

// 获取当前活动类型需要展示的字段
export function getActiveFiles(params) {
  return request({
    url: `/system/acddActivityField/selectActivityField`,
    method: 'get',
    params
  })
}

// 生成卡券
export function generateCardRoll(params) {
  return request({
    url: `/system/acddCardRollCode/generateCardRoll`,
    method: 'GET',
    params
  })
}


// 券码情况 -- 列表
export function generateCardRollList(params) {
  return request({
    url: `/system/acddCardRollCode/list`,
    method: 'GET',
    params
  })
}

// 技术服务费
export function getServeFee(activeTypeId) {
  return request({
    url: `/system/acddShopAndActivityType/getServeFee/${activeTypeId}`,
    method: 'GET'
  })
}

// 自建/官方服务
export function buildOneselfServe(params) {
  return request({
    url: `/system/acddServe/buildOneselfServe`,
    method: 'GET',
    params
  })
}

// 根据商户池获取商户列表
export function getShopListByPool(ids) {
  return request({
    url: `/system/acddShop/getPoolInfo/${ids}`,
    method: 'GET'
  })
}


// 活动价格计算
export function priceCalculation(activeId) {
  return request({
    url: `/system/acddActivity/priceCalculation/${activeId}`,
    method: 'post'
  })
}

// 设置活动通用配置
export function setH5Config(data) {
  return request({
    url: `/system/acddActivityPageConf/add`,
    method: 'post',
    data
  })
}

// 获取活动通用配置
export function getH5Config(activeId) {
  return request({
    url: `/system/acddActivityPageConf/getPageConfInfo/${activeId}`,
    method: 'get'
  })
}

// 获取活动链接
export function getH5Link(activeId) {
  if(!activeId) return Promise.resolve({data: {}})
  return request({
    url: `/system/acddActivity/getActivityImgUrl/${activeId}`,
    method: 'get'
  })
}


// 导出未核销券码
export function exportTicket(params, filename) {
  return download('/system/acddCardRollCode/export', params, `${filename}${getNowDate()}.xlsx`)
}


// 支付
export function activityPay(data) {
  return request({
    url: `/system/acddActivity/activityPay`,
    method: 'post',
    data
  })
}

// 修改活动时间
export function editActivityDate(data) {
  return request({
    url: `/system/acddActivity/updateDate`,
    method: 'post',
    data
  })
}

// 修改活动时间
export function batchPrice(data) {
  return request({
    url: `/system/acddActivity/priceCalculationList`,
    method: 'post',
    data
  })
}
export function batchPay(data) {
  return request({
    url: `/system/acddActivity/activityPayList`,
    method: 'post',
    data
  })
}


